package io.renren.modules.generator.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.WgzBedArrangementDao;
import io.renren.modules.generator.entity.WgzBedArrangementEntity;
import io.renren.modules.generator.service.WgzBedArrangementService;
import org.springframework.util.StringUtils;


@Service("wgzBedArrangementService")
public class WgzBedArrangementServiceImpl extends ServiceImpl<WgzBedArrangementDao, WgzBedArrangementEntity> implements WgzBedArrangementService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<WgzBedArrangementEntity> wgzBedArrangementEntityQueryWrapper = new QueryWrapper<>();

        if (!StringUtils.isEmpty(params.get("oldId"))){
            wgzBedArrangementEntityQueryWrapper.eq("old_id",params.get("oldId"));
        }
        if (!StringUtils.isEmpty(params.get("building"))){
            wgzBedArrangementEntityQueryWrapper.eq("building",params.get("building"));
        }
        if (!StringUtils.isEmpty(params.get("roomId"))){
            wgzBedArrangementEntityQueryWrapper.eq("room_id",params.get("roomId"));
        }
        if (!StringUtils.isEmpty(params.get("bedId"))){
            wgzBedArrangementEntityQueryWrapper.eq("bed_id",params.get("bedId"));
        }
        IPage<WgzBedArrangementEntity> page = this.page(
                new Query<WgzBedArrangementEntity>().getPage(params),
                wgzBedArrangementEntityQueryWrapper
        );

        return new PageUtils(page);
    }

}